﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.AdminPage
{

    public partial class FrmDoRole : System.Web.UI.Page
    {
        public List<Model.View_Role> list=new List<Model.View_Role>();

        public int RoleId;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int Id = Convert.ToInt32(Request.QueryString["Id"]);
                RoleId = Id;
                var mlist = Common.SqlExption.GetList<Model.tb_menu>();
                var rumlist = Common.SqlExption.GetList<Model.tb_role_user>().Where(c=>c.rid.Equals(Id)).ToList();
                foreach (var item in mlist)
                {
                    Model.View_Role m = new Model.View_Role();
                    m.Id = item.Id;
                    m.Name = item.Name;
                    m.Pid = item.Pid;
                    m.Urls = item.Urls;
                    m.isSelect = false;
                    m.GXId = 0;
                    foreach (var itemrole in rumlist)
                    {
                        if (item.Id.Equals(itemrole.mid))
                        {
                            m.GXId = itemrole.Id;
                            m.isSelect = true;
                            break;
                        }
                    }
                    list.Add(m);
                    
                }
            }
        }
    }
}